<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-idleResult-edit" th:object="${idleResult}">
            <input id="idleId" name="idleId" th:field="*{idleId}"  type="hidden">
            <div class="form-group">	
                <label class="col-sm-3 control-label">证件号码：</label>
                <div class="col-sm-8">
                    <input id="empId" name="empId" th:field="*{empId}" class="form-control" type="text" readonly="readonly" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">姓名：</label>
                <div class="col-sm-8">
                    <input id="empNm" name="empNm" th:field="*{empNm}" class="form-control" type="text" readonly="readonly" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">供应商名称：</label>
                <div class="col-sm-8">
                    <input id="compNm" name="compNm" th:field="*{compNm}" class="form-control" type="text" readonly="readonly" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">缺勤日期：</label>
                <div class="col-sm-8">
                	<input type="text" class="form-control time-input" id="idleDate" name="idleDate" th:value="${#dates.format(idleResult.idleDate, 'yyyy-MM-dd')}" readonly="readonly" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">缺勤说明：</label>
                <div class="col-sm-8">
                    <input id="idleNote" name="idleNote" th:field="*{idleNote}" class="form-control" type="text">
                </div>
            </div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "pm/idleResult";
		$("#form-idleResult-edit").validate({
			rules:{
				empId:{
        			required:true
        		},
        		empNm:{
        			required:true
        		}
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	edit();
	        }
	    }
		
		layui.use('laydate', function(){
			var laydate = layui.laydate;
			laydate.render({
				elem: '#idleDate',
				theme: 'default',
		        trigger: 'click'
			});
		});
		
		function edit() {
			var idleId = $("input[name='idleId']").val();
			var empId = $("input[name='empId']").val();
        	var empNm = $("input[name='empNm']").val();
        	var compNm = $("input[name='compNm']").val();
        	var idleDate = $("#idleDate").val();
        	var idleNote = $("input[name='idleNote']").val();
        	$.ajax({
        		cache : true,
        		type : "POST",
        		url : ctx + "pm/idleResult/edit",
        		data : {
        			"idleId": idleId,
        			"empId": empId,
        			"empNm": empNm,
        			"compNm": compNm,
        			"idleDate": idleDate,
        			"idleNote": idleNote
        		},
        		async : true,
        		error : function(request) {
        			$.modal.alertError("系统错误");
        		},
        		success : function(data) {
        			$.operate.saveSuccess(data);
        		}
        	});
        }
	</script>
</body>
</html>
